/*
 * StartupBasePanelHandler
 * 
 * Version: 1.0: This class is responsible for generating Starup Base Panel, which is is base panel for all the other
 * panels which contain configuration controls
 * 
 * Date: 12/05/2010
 * 
 * Licensed under Eclipse open source license
 */
package slhs.tempo.scriptGenerator;

import java.awt.LayoutManager;
import java.awt.event.ActionEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;

import org.mlc.swing.layout.LayoutConstraintsManager;

public class StartupBasePanelHandler extends JPanel implements PanelHandler {

    private static final String STARTUP_BASE_PANEL_LAYOUT_XML_FILE = "STARTUP_BASE_PANEL_LAYOUT5.XML";

    private JPanel startupBasePanel;
    private JPanel fontParametersPanel;
    private JPanel experimentalParametersPanel;
    private JPanel buttonPanel;
    private JPanel screensHolderPanel;

    private JFrame startupFrame;

    private FontParametersPanelHandler fontParametersPanelHandler;
    private ExperimentalParametersPanelHandler experimentalParametersPanelHandler;
    private ButtonPanelHandler buttonPanelHandler;

    public StartupBasePanelHandler(JPanel screensHolderPanel, JFrame startupFrame) {
	startupBasePanel = new JPanel();
	this.screensHolderPanel = screensHolderPanel;
	this.startupFrame = startupFrame;
	initComponents();
	addComponents();
	startupFrame.setSize(870, 490);
    }

    private void initComponents() {
	fontParametersPanelHandler = FontParametersPanelHandler.getInstance();
	fontParametersPanel = fontParametersPanelHandler.getPanel();

	experimentalParametersPanelHandler = ExperimentalParametersPanelHandler.getInstance();
	experimentalParametersPanel = experimentalParametersPanelHandler.getPanel();

	buttonPanelHandler = new ButtonPanelHandler(screensHolderPanel, startupFrame);
	buttonPanel = buttonPanelHandler.getPanel();
    }

    private void addComponents() {

	LayoutConstraintsManager layoutConstraintsManager = LayoutConstraintsManager.getLayoutConstraintsManager(this
		.getClass().getResourceAsStream(STARTUP_BASE_PANEL_LAYOUT_XML_FILE));
	LayoutManager panelLayout = layoutConstraintsManager.createLayout("panel", this);
	startupBasePanel.setLayout(panelLayout);

	startupBasePanel.add(fontParametersPanel, "fontParametersPanel");
	startupBasePanel.add(experimentalParametersPanel, "experimentalParametersPanel");
	startupBasePanel.add(buttonPanel, "buttonPanel");
    }

    @Override
    public JPanel getPanel() {
	return startupBasePanel;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
	// Can be used for dialogue generation later, if the user decides to
	// quit in the middle

    }

}
